package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.ContactBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BasePageListBean;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.IContactView;

import java.util.List;
import java.util.Map;

/**获取发送邮箱 联系人列表
 * Created by admin on 2017/12/1.
 */

public class ContactPest {
    private IContactView iContactMyGroupView;

    public ContactPest(IContactView iContactMyGroupView) {
        this.iContactMyGroupView=iContactMyGroupView;
    }
    //获取站内列表
    public void getContactList(Context context, String word_search,int page,int rows){
        Map<String,Object> map = HeadParamBean.getHead(context);
        if (!BaseUtil.isEmpty(word_search)){
            map.put("word_search",word_search);
        }
        map.put("page",page);
        map.put("rows",rows);
        new ApiManager().getContactList(map, new BaseCallBack<BaseResult<BasePageListBean<ContactBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<ContactBean>> response) {
                iContactMyGroupView.getContactListSuccess(response.getData().rows);
            }
            @Override
            public void onFailures(String message) {
                iContactMyGroupView.showError(message);
            }
        });
    }
    //获取群组列表
    public void getContactMyGroupList(Context context){
        Map<String,Object> map = HeadParamBean.getHead(context);
        new ApiManager().getContactMyGroupList(map, new BaseCallBack<BaseResult<List<ContactBean>>>() {
            @Override
            public void onSuccess(BaseResult<List<ContactBean>> response) {
                iContactMyGroupView.getContactListSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iContactMyGroupView.showError(message);
            }
        });
    }
    //获取层级列表
    public void getContactOrgLevelList(Context context){
        Map<String,Object> map = HeadParamBean.getHead(context);
        new ApiManager().getContactOrgLevelList(map, new BaseCallBack<BaseResult<List<ContactBean>>>() {
            @Override
            public void onSuccess(BaseResult<List<ContactBean>> response) {
                iContactMyGroupView.getContactListSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iContactMyGroupView.showError(message);
            }
        });
    }
}
